package com.yami.shop.mystery.platform.listener;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.yami.shop.bean.event.GrantEvent;
import com.yami.shop.bean.model.UserAddr;
import com.yami.shop.mystery.common.model.InviteRecord;
import com.yami.shop.mystery.common.service.InviteRecordService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component;

/**
 * 功能描述: 拉新奖励发放 回调
 * @Author: LSR
 * @Date: 2023/8/30 16:49
 */

@Slf4j
@Component("grantListener")
@AllArgsConstructor
public class GrantListener {

    @Autowired
    private InviteRecordService inviteRecordService;

    @EventListener(GrantEvent.class)
    public void inviteListener(GrantEvent event) {
        inviteRecordService.update(Wrappers.lambdaUpdate(InviteRecord.class).set(InviteRecord::getStatus, event.getStatus()).eq(InviteRecord::getId, event.getInviteRecordId()));
    }

}
